﻿using System;
using System.ServiceModel;
using Ayatta.Contract.Domain;
using System.Collections.Generic;

namespace Ayatta.Contract
{
    [ServiceContract(Namespace = ServiceContract.Namespace)]
    public interface IPassportService : IService
    {
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        [OperationContract]
        int UserCreate(User o);

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="name">用户名/绑定邮箱/绑定手机号</param>
        /// <param name="password">登录密码</param>
        /// <returns></returns>
        [OperationContract]
        User UserSignIn(string name, string password);

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="id">Id</param>
        /// <param name="profile">是否包含UserProfile</param>
        /// <param name="extra">是否包含UserExtra</param>
        /// <returns></returns>
        [OperationContract]
        User UserGet(int id, bool profile = false, bool extra = false);

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="guid">guid</param>
        /// <returns></returns>
        User UserGetByGuid(string guid);

        /// <summary>
        /// 检查用户是否已存在
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [OperationContract]
        MagicKit<int> UserExist(string name);

        [OperationContract]
        bool UserEmailBind(int userId, string email);

        [OperationContract]
        bool UserMobileBind(int userId, string mobile);

        [OperationContract]
        bool UserAvatarUpdate(int id, bool avatar);

        [OperationContract]
        bool UserNicknameUpdate(int userId, string nickname);

        [OperationContract]
        bool UserPasswordUpdate(int userId, string password);

        /// <summary>
        /// 添加预注册用户
        /// </summary>
        /// <param name="o">预注册用户</param>
        /// <returns></returns>
        [OperationContract]
        bool PreUserCreate(PreUser o);

        [OperationContract]
        PreUser PreUserGet(string id);


        #region UserProfile

        [OperationContract]
        bool UserProfileUpdate(UserProfile o, bool authenticated);

        [OperationContract]
        UserProfile UserProfileGet(int id);

        [OperationContract]
        PagedList<UserProfile> UserProfilePagedList(int page = 1, int size = 20);

        #endregion

        #region UserAddress

        [OperationContract]
        bool UserAddressCreate(UserAddress o);

        [OperationContract]
        bool UserAddressUpdate(UserAddress o);

        [OperationContract]
        bool UserAddressDelete(int id, int? userId);

        [OperationContract]
        UserAddress UserAddressGet(int id, int? userId);

        [OperationContract]
        IList<UserAddress> UserAddressList(int? userId);

        [OperationContract]
        bool UserAddressSetDefault(int id, int userId, AddressCategory category);

        #endregion


        #region UserInvoice

        [OperationContract]
        bool UserInvoiceCreate(UserInvoice o);

        [OperationContract]
        bool UserInvoiceUpdate(UserInvoice o);

        [OperationContract]
        bool UserInvoiceDelete(int id);

        [OperationContract]
        UserInvoice UserInvoiceGet(int id);

        [OperationContract]
        IList<UserInvoice> UserInvoiceList(int? userId = null);

        [OperationContract]
        PagedList<UserInvoice> UserInvoicePagedList(int page = 1, int size = 20);

        #endregion


        #region OAuth

        [OperationContract]
        bool OAuthCreate(OAuth o);

        [OperationContract]
        bool OAuthUpdate(OAuth o);

        [OperationContract]
        bool OAuthDelete(int id);

        [OperationContract]
        OAuth OAuthGet(int id);

        [OperationContract]
        IList<OAuth> OAuthList();

        #endregion

        #region OAuthUser

        [OperationContract]
        void OAuthUserSignIn(OAuthUser o);

        [OperationContract]
        OAuthUser OAuthUserGet(string openId, string createdBy);

        #endregion OAuthUser
    }
}